<template>
    <div class="newsinfo_content">
        <h1>{{newsinfo.title}}</h1>
        <p class="p_des">
            <span>发表时间：{{newsinfo.add_time | timeFil}}</span>
            <span>点击次数：{{newsinfo.click}}</span>
        </p>
        <hr>
        <div class="content" v-html="newsinfo.content"></div>
        <!-- 评论子组件 -->
        <comment :id="this.id"></comment>
    </div>
</template>

<script>
    import comment from '../soncomponents/comment.vue'
    export default {
        data () {
            return {
                id:this.$route.params.id,
                newsinfo:{}
            }
        },
        components: {
          comment  
        },
        created () {
          this.getnewsinfo(); 
        },
        methods: {
            getnewsinfo(){
                this.$http.get('api/getnew/'+this.id).then(res=>{
                    // console.log(res.body.message[0]);
                    this.newsinfo = res.body.message[0];
                });
            }
        }
    }
</script>

<style lang="scss">
    .newsinfo_content{
        padding: 5px 10px;
        h1{
            color: red;
            font-size: 16px;
            text-align: center;
        }
        .p_des{
            color: #007aff;
            font-size: 14px;
            display: flex;
            justify-content: space-between;
        }
        img{
            width: 100%;
            height: 100%;
        }
    }

</style>